package com.wisely.ch8_6_1.service.person;

import com.wisely.ch8_6_1.domain.Person;
import com.wisely.ch8_6_1.repository.IPersonDao;
import com.wisely.ch8_6_1.service.IPersonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PersonServiceImpl implements IPersonService{
    @Autowired
    private IPersonDao personDao;


    @Override
    public void save(Person person) {
        personDao.valOps(person.getName(),person);
        personDao.save(person);
    }

    @Override
    public Person findByName(String name) {
        //Person p = personDao.findByName(name);
        Person p = (Person) personDao.getObject(name);
        return p;
    }

    @Override
    public List<Person> withQueryFindByAge(Integer age) {
        return personDao.withQueryFindByAge(age);
    }
}
